package com.longlong.controller;


import com.longlong.utils.QiniuUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 七牛文件上传下载控制器
 */

@RestController
@RequestMapping("/tool")
public class QiniuController {


    @Autowired
    private QiniuUtil qiniuUtil;

    @PostMapping("/uploadFile")
    public Object upload(@RequestBody MultipartFile file) throws IOException {
        String url = qiniuUtil.upload(file.getInputStream(), file.getOriginalFilename());
        return url;
    }
}
